- /* siosiand.cpp by K.Tsuru */
- // function ID = 408 DRADIX, BRADIX
- /*******************************************
- SInteger class
- It provides the bit "and" oparattion m & n.
- ********************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SInteger operator&(const SInteger& m, const SInteger& n){
- if( m.Sign(408) == 0) return m; // return 0.0;
- if( n.Sign(408) == 0) return n;
-
- const fType* mv;
- const fType* nv;
- uint t, h;
- mv = m.ReadFigures();
- nv = n.ReadFigures();
- h = max(m.Head(), n.Head()); // aHead --> Head() since ver 2.191
- t = min(m.Tail(), n.Tail());
-
- SInteger result;
-
- if( h < t ) {
- result.SetZero(); return result; // ver.2.17
- }
- result.valloc(h + 1u, -1);
- result.figure.clear(0, t);
- result.figure.clear(h + 1u);
- fType* rv = result.figure.Elements();
- for(register uint i = t; i <= h; i++){
- rv[i] = mv[i] & nv[i];
- }
- while( !rv[t] && t <= h ) t++;
- if( h < t ) { // Here rv[h] = 0 and t = h + 1 i.e. result = 0.
- result.SetZero(); return result; // ver.2.17
- }
-
- // Below result != 0.
- result.aTail = t;
- while( !rv[h] && h > t ) h--;
- result.aHead = h;
-
- result.SetSign(1);
- // It reduces the size if possible.
- if( 2u * (result.aHead + 1) <= result.figure.size() ) result.DoCutDown();
- return result;
- }
siosiand.cpp : last modifiled at 2017/03/13 14:32:00(1,301 bytes)
created at 2016/04/25 14:53:17
The creation time of this html file is 2017/10/25 11:09:45 (Wed Oct 25 11:09:45 2017).